<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="m" value="${memberRead}"/>
<link type="text/css" href="css/member_modify.css" rel="stylesheet" />
<div id="contents">
	<%@ include file="../tiles/modifymnmn.jspf" %>
	<ul id="loca">
		<li><a href="">홈</a>&nbsp;&gt;</li>
		<li>Mypage</li>
	</ul>

	<div class="modal-content" id="modify-body">
    <form name="joinFs" method="post" id="joinFs" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h2 class="modal-title" id="loginModalLabel">회원정보 수정</h2>
      </div>
			<div class="modal-body" id="modal-bodyid">
				
					<div>
						<label for="juid" id="juid">${sessionScope.uid }</label>
					</div>
					<label for="pwdchk" class="blind">비밀번호확인</label>
					<input type="password" name="rpwd" id="rpwd" title="비밀번호확인" placeholder="비밀번호 확인" onkeyup="checkPwd()" />
					<span id="pwdresult"></span> 
					<label for="namet" class="blind">이름</label> 
					<input type="text" name="namet" id="namet" title="이름" placeholder="이름" value="${m.uname }" /> 
						<div id="genre">				
						<select name="ugenre1" id="genre1" title="장르" >
							<option selected="selected" id="gen1">${m.ugenre1}</option>
							<option>액션</option>
							<option>코미디</option>
							<option>애로</option>
							<option>로맨스</option>
							<option>공포/스릴러</option>
							<option>전쟁</option>
							<option>SF</option>
						</select><br /><br />
						<select name="ugenre2" id="genre2" title="장르">
							<option selected="selected" id="gen2">${m.ugenre2}</option>
							<option>액션</option>
							<option>코미디</option>
							<option>애로</option>
							<option>로맨스</option>
							<option>공포/스릴러</option>
							<option>전쟁</option>
							<option>SF</option>
						</select><br /><br />
						</div>	
		        	<div>
						<input type="text" name="zip1" id="zip1" class="form-control" required="required" readonly="readonly" />
						<input type="text" name="zip2" id="zip2" class="form-control" required="required" readonly="readonly" />
						<button type="button" id="findzipcode" class="btn btn-info" data-toggle="modal" data-target="#zipcodeModal">우편번호 찾기</button>
						<input type="text" name="addr1" id="addr1" class="form-control" readonly="readonly" value="${m.addr}" />
						<label for="addr2" class="blind">나머지주소</label>
						<input type="text" name="addr2" id="addr2" class="form-control" placeholder="나머지 주소"  title="나머지주소" />
					</div>	
					<label for="hpt" class="blind" >휴대폰</label>	
					<input type="text" name="hpt" id="hpt" title="휴대폰" placeholder="휴대폰" value="${m.phone }" />	
					<label for="emt" class="blind">이메일</label>	
					<input type="text" name="emt" id="emt" title="이메일" placeholder="이메일" value="${m.email }" />	
				
			</div>
			<span id="joinokresult"></span> 
			
			<div class="modal-footer">
				<button type="button" class="btn btn-default" id="updatebtn" onclick="modifyok()" >수정완료</button>
				<button type="button" class="btn btn-default" data-dismiss="modal" >수정취소</button>
			</div>
		</form>	
		</div>
</div><!-- /.modal-content -->

<div class="modal fade" id="zipcodeModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="zipcodeModalLabel">우편번호 찾기</h4>
			</div>
			<div class="modal-body">
				<div>
					<label for="uid" class="blind">동이름 검색</label> <input type="text"
						name="dong" id="dong" class="form-control"
						title="검색할 주소의 동이름을 입력하세요" placeholder="검색할 주소의 동이름을 입력하세요" />
					<button type="button" class="btn btn-danger" id="findbtn">검
						색</button>
				</div>
				<div>
					<select id="ziplist" class="form-control" size="10">
					</select>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-primary" id="okbtn"
					data-dismiss="modal">확 인</button>
				<button type="button" class="btn btn-default" id="closebtn"
					data-dismiss="modal">닫 기</button>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal-dialog -->
</div>
<!-- /.modal -->


<script src="../js/jquery1.10.2.min.js"></script>
<script>

function modifyok(){
	if($("#rpwd").val() == "" || $("#namet").val() == "" || $("#genre1").val() == "" ||
			$("#genre2").val() == "" || $("#addr1").val() == "" || $("#addr2").val() == "" ||
			$("#hpt").val() == "" || $("#emt").val() == "")
		alert("빈칸을 채워 주세요");
	else if
		($("#rpwd").val() != "${m.pwd}" )
			alert("정확한 비밀번호를 입력해 주세요");
			/*alert("${m.pwd}");*/
			
	else if
		($("#rpwd").val() == "${m.pwd}" )
			var frm = document.getElementById("joinFs");
			frm.action = "mem_update.bi";
			frm.method = "post";
			frm.submit();
		}
</script>


<script>
	/* 우편번호 찾기 */
	$("#findbtn").click(function() {
		if ($("#dong").val() != "") {
			$("#ziplist *").remove();
			var reqAjax = $.ajax({
				url : "zipcode.bi",
				type : "POST",
				data : {
					dong : $("#dong").val()
				}
			});
			reqAjax.done(function(result) {
				$(result).appendTo("#ziplist");
			});
			reqAjax.fail(function(jqXHR, status) {
				alert("error : " + status);
			});
		} else {
			alert("검색어를 입력하세요");
		}
	}); // 검색버튼
	$("#okbtn").click(function() {
		var selectOne = $("#ziplist").val().split(" ");
		$("#zip1").val(selectOne[0].split("-")[0]);
		$("#zip2").val(selectOne[0].split("-")[1]);
		var s = selectOne[1];
		for (var i = 2; i < selectOne.length; ++i) {
			s = s + " " + selectOne[i];
		}
		$("#addr1").val(s);
		$("#ziplist *").remove();
	});
	$("#closebtn").click(function() {
		$("#ziplist *").remove();
	});

	$("#successbtn").click(function() {
		location.href = 'index.bi';
	});

	/* function openPop(){
	 {
	 window.open("http://www.naver.com", "startpop", "width=800, height=500, scrollbars=no, resizable=no ,status=no ,toolbar=no");
	 }
	 } */
</script>
 